<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('编辑客户')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-edit" th:object="${orders}">
        <input id="orderId" name="orderId" type="hidden" th:field="*{orderId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label">设备名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="itemName" id="itemName" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">设备编号：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="collId" id="collId" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">设备类型：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="deptId" id="deptId" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">设备数量：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="collId" id="collId1" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否可用：</label>
            <div class="col-sm-8">
                <select name="paymentMethod" class="form-control m-b" >
                    <option>有</option>
                    <option>无</option>
                </select>
                <!--<input class="form-control" type="text" name="paymentMethod" id="paymentMethod" required>-->
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注信息：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control"></textarea>
            </div>
        </div>

    </form>

</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "sell/order";

    $("#form-post-edit").validate({
        onkeyup: false,
        rules:{
            itemName:{
                remote: {
                    url: ctx + "sell/order/checkOrderNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "orderId": function() {
                            return $("input[name='orderId']").val();
                        },
                        "itemName" : function() {
                            return $.common.trim($("#itemName").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            cusSort:{
                digits:true
            },
        },
        messages: {
            "itemName": {
                remote: "项目名称已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
        }
    }
</script>
</body>
</html>
